package com.jch.ts;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelProgressiveFuture;
import io.netty.util.internal.shaded.org.jctools.queues.MessagePassingQueue;

public class TsServerHandler extends TSCommonHandler {

    @Override
    protected void sendData(ChannelHandlerContext ctx) {
        sendFlag = true;
        ctx.writeAndFlush("1234567890一二三四五六七八九零壹贰叁肆伍陆柒捌玖零十\r\n",getChannelProgressivePromise(ctx, new MessagePassingQueue.Consumer<ChannelProgressiveFuture>() {
            @Override
            public void accept(ChannelProgressiveFuture e) {
                if (ctx.channel().isWritable() && !sendFlag){ // 是否写
                    sendData(ctx);
                }
            }
        }));
    }
}
